﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FileRetrieval
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        public Dictionary<string, string> configs = new Dictionary<string, string>();
        private void Form1_Load(object sender, EventArgs e)
        {
            LoadACQRateConfig();
        }

        public void LoadACQRateConfig()
        {
            string path = System.AppDomain.CurrentDomain.BaseDirectory;
            using (StreamReader sr = new StreamReader(path + "Config.txt", Encoding.UTF8))
            {
                try
                {
                    while (!sr.EndOfStream)
                    {
                        string line = sr.ReadLine();
                        string[] cells = line.Split(';');
                        string key = cells[0];
                        string content = cells[1];

                        if (!configs.ContainsKey(key))
                        {
                            configs.Add(key, content);
                        }
                    }
                }
                catch
                {

                }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            label2.Text = "开始";
            var dataPath = txtDataPath.Text;
            if (!string.IsNullOrEmpty(dataPath))
            {
                FileUtils.TestGetCurrentFileList(dataPath, configs);
            }
            label2.Text = "结束";
        }

        private void btnDataPathBrowse_Click(object sender, EventArgs e)
        {
            using (FolderBrowserDialog browserDialog = new FolderBrowserDialog())
            {
                if (browserDialog.ShowDialog() == DialogResult.OK)
                {
                    txtDataPath.Text = browserDialog.SelectedPath;
                }
            }
        }

    }
}
